<template>
  <view :style="themeColor">
    <view class="page">
      <fu-custom :isBack="true" bgColor="bg-white" class="header" :isBottom="true">
        <block slot="content">提现</block>
        <block slot="right">
          <view @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/wd/withdrawalDetail/withdrawalDetail`" class="text-red title-right ">明细</view>
        </block>
      </fu-custom>

      <view class="flex flex-direction align-stretch benben-flex-layout commissionWithdrawals_flex_1">
        <view class='flex flex-direction align-stretch commissionWithdrawals_fd1_0'>
          <text class='commissionWithdrawals_fd1_0_c0'>输入提现金额</text>
          <view class='flex flex-wrap align-center justify-between commissionWithdrawals_fd1_0_c1'>
            <view class='flex flex-wrap align-center flex-sub commissionWithdrawals_fd1_0_c1_c0'>
              <text class='commissionWithdrawals_fd1_0_c1_c0_c0'>￥</text>
              <input class='flex-sub commissionWithdrawals_fd1_0_c1_c0_c1' type="text"
                :placeholder="`账户余额${dataMoney.available}`" confirm-type="done" :maxlength="-1"
                placeholder-style="color:#999;font-size:32rpx" v-model="cash_fee" />
            </view>
            <text class='commissionWithdrawals_fd1_0_c1_c1' @tap.stop="allmoneyFunc()">全部</text>
          </view>
          <view class='flex flex-wrap align-center commissionWithdrawals_fd1_0_c2'>
            <text class='commissionWithdrawals_fd1_0_c2_c0'>{{rules}}</text>
            <text class='fu-iconfont2  commissionWithdrawals_fd1_0_c2_c1'
              @tap.stop="popupShow1673862116532=true">&#xE600;</text>
          </view>
        </view>
        <view class='flex flex-direction align-stretch commissionWithdrawals_fd1_1'>
          <text class='commissionWithdrawals_fd1_1_c0'>请选择提现方式</text>
          <template v-for='(item,key0) in dataType'>
            <view class='flex flex-wrap align-center commissionWithdrawals_fd1_1_c1'
              @tap.stop="getselectmessageFunc(item)" :key='key0'>
              <image class='commissionWithdrawals_fd1_1_c1_c0' mode="aspectFit" :src='item.thumb'></image>
              <text class='commissionWithdrawals_fd1_1_c1_c1'>{{item.method_name}}</text>
              <image class='commissionWithdrawals_fd1_1_c1_c2' mode="aspectFit" :src='STATIC_URL+"3.png"'
                v-if=" item.method_code==embody_id"></image>
              <image class='commissionWithdrawals_fd1_1_c1_c2' mode="aspectFit" :src='STATIC_URL+"312.png"'
                v-if=" item.method_code!=embody_id"></image>
            </view>
          </template>

        </view>
        <view class='flex flex-wrap align-center justify-center commissionWithdrawals_fd1_2'>
          <button class='commissionWithdrawals_fd1_2_c0' @tap.stop="queryMessageFunc()">提交</button>
        </view>
      </view>


      <benben-popup v-model="popupShow1673862116532" :mask="true" :mask-close-able="true" mode='center'>
        <!---富文本弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center benben-flex-layout">
          <view class='flex flex-direction flex-wrap align-center commissionWithdrawals_fd2_0'>
            <text class='commissionWithdrawals_fd2_0_c0'>{{dataEssay.name}}</text>

            <scroll-view class='commissionWithdrawals_fd2_0_c1' :scroll-y='true'>
              <view class='flex benben-scroll flex align-center'>
                <jyf-parser class='commissionWithdrawals_fd2_0_c1_c0' :html="dataEssay.content | richTextFormat">
                </jyf-parser>
              </view>
            </scroll-view>

          </view>
          <image class='commissionWithdrawals_fd2_1' mode="aspectFit" :src='STATIC_URL+"313.png"'
            @tap.stop="popupShow1673862116532=false"></image>
        </view>

        <!---富文本弹窗flex布局结束-->

      </benben-popup>
      <benben-popup v-model="popupShow1686628262181" :mask="true" :mask-close-able="true" mode='center'>
        <!---未绑定微信弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center commissionWithdrawals_flex_3">
          <text class='commissionWithdrawals_fd3_0'>还未绑定微信,是否前往绑定?</text>
          <view class='flex align-center'>
            <button class='commissionWithdrawals_fd3_1_c0' @tap.stop="popupShow1686628262181=false">取消</button>
            <button class='commissionWithdrawals_fd3_1_c1' @tap.stop="gowxFunc()">确定</button>
          </view>
        </view>

        <!---未绑定微信弹窗flex布局结束-->

      </benben-popup>
      <benben-popup v-model="popupShow1686628821361" :mask="true" :mask-close-able="true" mode='center'>
        <!---未绑定支付宝弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center commissionWithdrawals_flex_4">
          <text class='commissionWithdrawals_fd4_0'>还未绑定支付宝,是否前往绑定?</text>
          <view class='flex align-center'>
            <button class='commissionWithdrawals_fd4_1_c0' @tap.stop="popupShow1686628821361=false">取消</button>
            <button class='commissionWithdrawals_fd4_1_c1' @tap.stop="goalipayFunc()">确定</button>
          </view>
        </view>

        <!---未绑定支付宝弹窗flex布局结束-->

      </benben-popup>
      <benben-popup v-model="popupShow1686629150177" :mask="true" :mask-close-able="true" mode='center'>
        <!---未绑定银行卡弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center commissionWithdrawals_flex_5">
          <text class='commissionWithdrawals_fd5_0'>还未绑定银行卡,是否前往绑定?</text>
          <view class='flex flex-wrap align-center'>
            <button class='commissionWithdrawals_fd5_1_c0' @tap.stop="popupShow1686629150177=false">取消</button>
            <button class='commissionWithdrawals_fd5_1_c1' @tap.stop="gobankFunc()">确定</button>
          </view>
        </view>

        <!---未绑定银行卡弹窗flex布局结束-->

      </benben-popup>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "popupShow1686629150177": false,
        "popupShow1686628821361": false,
        "popupShow1686628262181": false,
        "popupShow1673862116532": false,
        "embody_id": "wx",
        "dataEssay": {
          "aid": "",
          "name": "",
          "thumb_img": "",
          "content": "",
          "introduce": ""
        },
        "cash_fee": "",
        "dataMessage": [],
        "dataType": [],
        "dataMoney": {
          "people_total": "",
          "people_first": "",
          "people_second": "",
          "award_total": "",
          "award_today": "",
          "award_month": "",
          "order_total": "",
          "order_month": "",
          "available": "",
          "frozen": ""
        },
        "is_bind": "",
        "method_fee": "",
        "method_max": "",
        "method_min": "",
        "rules": "",
        "method_name": "微信"
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.getWenzhangFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.searchAccountFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //点击全部
      allmoneyFunc() {
        this.cash_fee = this.dataMoney.withdrawal_money;
      },
      //获取支付方式
      async searchAccountFunc() {
        //请求方法
        //数据验证

        let datadataType = await this.$api.get(global.apiUrls.post62fc4f70a9d44, {
          scene: 'money'
        });

        if (datadataType.data.code != 1) {
          this.$message.info(datadataType.data.msg);
          return
        }
        let infodataType = datadataType.data;
        this.dataType = infodataType.data

        if (this.dataType) {
          this.is_bind = this.dataType[0].is_bind;
          this.method_fee = this.dataType[0].method_fee;
          this.method_max = this.dataType[0].method_max;
          this.method_min = this.dataType[0].method_min;
          this.rules = this.dataType[0].rules;
          this.embody_id = this.dataType[0].method_code;
          this.method_name = this.dataType[0].method_name;
        }
        this.getMoneyFunc()
      },
      //获取选择类型信息
      getselectmessageFunc(item) {
        this.is_bind = item.is_bind;
        this.method_fee = item.method_fee;
        this.method_max = item.method_max;
        this.method_min = item.method_min;
        this.rules = item.rules;
        this.embody_id = item.method_code;
        this.method_name = item.method_name;
        if (this.is_bind == 0) {
          if (this.embody_id == 'wx') {
            this.$message.info('还未绑定微信，请先绑定微信');
          }
          if (this.embody_id == 'alipay') {
            this.$message.info('还未绑定支付宝，请先绑定支付宝');
          }
          if (this.embody_id == 'bank') {
            this.$message.info('还未绑定银行卡，请先绑定银行卡');
          }
        }
      },
      //提现
      queryMessageFunc() {
        if (!validate(this.cash_fee, 'require')) {
          this.$message.info('请输入提现金额');
          return false;
        }
        if (this.cash_fee > +this.dataMoney.available) {
          this.cash_fee = '';
          this.$message.info('余额不足，请重新输入金额');
          return
        }
        if (this.is_bind == 0) {
          if (this.embody_id == 'wx') {
            this.popupShow1686628262181 = true;
          } else if (this.embody_id == 'alipay') {
            this.popupShow1686628821361 = true;
          } else if (this.embody_id == 'bank') {
            this.popupShow1686629150177 = true;
          }
        } else {
          this.postWithdrawalFunc()
        }
      },
      //跳转绑定微信
      gowxFunc() {
        this.popupShow1686628262181 = false;
        this.$urouter.navigateTo(`/pages/wd/bindWechat/bindWechat?type=`);
      },
      //跳转支付宝
      goalipayFunc() {
        this.popupShow1686628821361 = false;
        this.$urouter.navigateTo(`/pages/wd/bindAlipay/bindAlipay?type=`);
      },
      //跳转银行卡
      gobankFunc() {
        this.popupShow1686629150177 = false;
        this.$urouter.navigateTo(`/pages/wd/bindBankCard/bindBankCard?type=`);
      },
      //发送提现接口
      async postWithdrawalFunc() {
        //请求方法
        //数据验证

        let datadataMessage = await this.$api.post(global.apiUrls.post636e4ff0626ef, {
          account_type: this.embody_id,
          cash_fee: this.cash_fee
        });

        if (datadataMessage.data.code != 1) {
          this.$message.info(datadataMessage.data.msg);
          return
        }
        let infodataMessage = datadataMessage.data;
        this.dataMessage = infodataMessage.data

        this.$urouter.redirectTo(`/pages/wd/application/application?type=${this.method_name}&money=${this.cash_fee}`);
      },
      //获取可提现金额
      async getMoneyFunc() {
        //请求方法
        //数据验证

        let datadataMoney = await this.$api.get(global.apiUrls.post62fb638cdfb64, {

        });

        if (datadataMoney.data.code != 1) {
          this.$message.info(datadataMoney.data.msg);
          return
        }
        let infodataMoney = datadataMoney.data;
        this.dataMoney = infodataMoney.data

      },
      //系统文章--获取系统单页内容
      async getWenzhangFunc() {
        //请求方法
        //数据验证

        let datadataEssay = await this.$api.get(global.apiUrls.post641568f1b6f87, {
          column_id: '3'
        });

        if (datadataEssay.data.code != 1) {
          this.$message.info(datadataEssay.data.msg);
          return
        }
        let infodataEssay = datadataEssay.data;
        this.dataEssay = infodataEssay.data

      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .commissionWithdrawals_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .commissionWithdrawals_fd0_0_c2_c0 {
    font-size: 32rpx;
    font-weight: 400;
    color: #333;
  }

  .commissionWithdrawals_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .commissionWithdrawals_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
  }

  .commissionWithdrawals_fd0_0_c0 {
    width: 180rpx;
  }

  .commissionWithdrawals_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .commissionWithdrawals_flex_1 {
    padding: 0rpx 0rpx 150rpx 0rpx;
  }

  .commissionWithdrawals_fd1_2_c0 {
    background: var(--benbenbgColor7);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    font-size: 32rpx;
    color: #fff;
    width: 686rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-weight: 700;
  }

  .commissionWithdrawals_fd1_2 {
    width: 750rpx;
    position: fixed;
    left: 0rpx;
    bottom: calc(40rpx + var(--window-bottom));
  }

  .commissionWithdrawals_fd1_1_c1_c2 {
    width: 36rpx;
    height: 36rpx;
    margin: 0rpx 0rpx 0rpx auto;
    border-radius: 18rpx 18rpx 18rpx 18rpx;
  }

  .commissionWithdrawals_fd1_1_c1_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
  }

  .commissionWithdrawals_fd1_1_c1_c0 {
    width: 52rpx;
    height: 52rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .commissionWithdrawals_fd1_1_c1 {
    border-bottom: 1px solid #eee;
    padding: 28rpx 0rpx 28rpx 0rpx;
  }

  .commissionWithdrawals_fd1_1_c0 {
    font-size: 32rpx;
    font-weight: 700;
    color: #333;
    margin: 0rpx 0rpx 8rpx 0rpx;
  }

  .commissionWithdrawals_fd1_1 {
    background: var(--benbenbgColor1);
    padding: 32rpx 32rpx 0rpx 32rpx;
    background-size: 100% auto !important;
    margin: 20rpx 0rpx 0rpx 0rpx;
  }

  .commissionWithdrawals_fd1_0_c2_c1 {
    margin: 0rpx 0rpx 0rpx 16rpx;
    color: rgba(191, 191, 191, 1);
    font-size: 26rpx;
  }

  .commissionWithdrawals_fd1_0_c2_c0 {
    line-height: 53rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #999999;
  }

  .commissionWithdrawals_fd1_0_c2 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .commissionWithdrawals_fd1_0_c1_c1 {
    font-size: 32rpx;
    font-weight: 500;
    color: var(--benbenFontColor5);
  }

  .commissionWithdrawals_fd1_0_c1_c0_c1 {
    padding: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
  }

  .commissionWithdrawals_fd1_0_c1_c0_c0 {
    font-size: 56rpx;
    font-weight: 400;
    color: #333333;
  }

  .commissionWithdrawals_fd1_0_c1_c0 {
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .commissionWithdrawals_fd1_0_c1 {
    border-bottom: 1px solid #eee;
  }

  .commissionWithdrawals_fd1_0_c0 {
    font-size: 32rpx;
    font-weight: 700;
    color: #333333;
  }

  .commissionWithdrawals_fd1_0 {
    background: var(--benbenbgColor1);
    padding: 32rpx;
    background-size: 100% auto !important;
  }

  .commissionWithdrawals_fd2_1 {
    width: 56rpx;
    height: 56rpx;
    border-radius: 28rpx 28rpx 28rpx 28rpx;
  }

  ::v-deep .commissionWithdrawals_fd2_0_c1_c0 {
    width: 480rpx;
  }

  .commissionWithdrawals_fd2_0_c1 {
    touch-action: none;
    height: 330rpx;
    width: 480rpx;
  }

  .commissionWithdrawals_fd2_0_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: rgba(51, 51, 51, 1);
    margin: 0rpx 0rpx 32rpx 0rpx;
  }

  .commissionWithdrawals_fd2_0 {
    background: #fff;
    width: 560rpx;
    background-size: 100% auto !important;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    padding: 28rpx 32rpx 45rpx 32rpx;
    margin: 0rpx 0rpx 40rpx 0rpx;
  }

  .commissionWithdrawals_flex_3 {
    background: #fff;
    width: 540rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .commissionWithdrawals_fd3_1_c1 {
    border-top: 1px solid #eee;
    border-left: 1px solid #eee;
    background: var(--benbenbgColor1);
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor5);
    padding: 0rpx 102rpx 0rpx 101rpx;
    font-weight: 500;
  }

  .commissionWithdrawals_fd3_1_c0 {
    border-top: 1px solid #eee;
    background: #fff;
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    padding: 0rpx 102rpx 0rpx 103rpx;
    font-weight: 400;
  }

  .commissionWithdrawals_fd3_0 {
    line-height: 44rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    margin: 91rpx 0rpx 88rpx 0rpx;
  }

  .commissionWithdrawals_flex_4 {
    background: #fff;
    width: 540rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .commissionWithdrawals_fd4_1_c1 {
    border-top: 1px solid #eee;
    border-left: 1px solid #eee;
    background: #fff;
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor5);
    padding: 0rpx 102rpx 0rpx 101rpx;
    font-weight: 500;
  }

  .commissionWithdrawals_fd4_1_c0 {
    border-top: 1px solid #eee;
    background: #fff;
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    padding: 0rpx 102rpx 0rpx 103rpx;
    font-weight: 400;
  }

  .commissionWithdrawals_fd4_0 {
    line-height: 44rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    margin: 91rpx 0rpx 88rpx 0rpx;
  }

  .commissionWithdrawals_flex_5 {
    background: #fff;
    width: 540rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .commissionWithdrawals_fd5_1_c1 {
    border-top: 1px solid #eee;
    border-left: 1px solid #eee;
    background: #fff;
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor5);
    padding: 0rpx 102rpx 0rpx 101rpx;
    font-weight: 500;
  }

  .commissionWithdrawals_fd5_1_c0 {
    border-top: 1px solid #eee;
    background: #fff;
    line-height: 94rpx;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    padding: 0rpx 102rpx 0rpx 103rpx;
    font-weight: 400;
  }

  .commissionWithdrawals_fd5_0 {
    line-height: 44rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    margin: 91rpx 0rpx 88rpx 0rpx;
  }
</style>